package com.fourth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fourth.dao.UbStockDao;
import com.fourth.service.UbStockService;
import com.ljx.entity.Stock;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author Mr.ma
 * @since 2023/3/9 10:44
 **/
@Service
public class UbStockServiceImpl implements UbStockService {
    @Resource
    private UbStockDao ubStockDao;


    @Override
    public Stock selectByGoodsId(String goodsId) {

        Stock stock = ubStockDao.selectByGoodsId(goodsId);
        return stock;
    }

    @Override
    public int updateStock(Stock stock) {
        return ubStockDao.updateById(stock);
    }

    @Override
    public int changeStockSellNum(String goodsid, Integer num) {
        Stock stock = ubStockDao.selectByGoodsId(goodsid);
        Integer integer = Integer.valueOf(stock.getSellNum());
        stock.setSellNum(String.valueOf(integer+num));
        return ubStockDao.updateById(stock);
    }
}
